using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace IUPUI.StellarResults.Client
{
	/// <summary>
	/// Form to calculate conversions.
	/// </summary>
	public partial class CalculatorForm : Form
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="CalculatorForm"/> class.
		/// </summary>
		public CalculatorForm()
		{
			InitializeComponent();
		}

		#region Actions
		/// <summary>
		/// Handles the Execute event of the m_CalculateDecimalFromDMSAction control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void m_CalculateDecimalFromDMSAction_Execute(object sender, EventArgs e)
		{
			m_DecimalTextBox1.Text = (ININ.GIS.GISUtilities.ConvertSexagecimalToDouble(
				(int)m_DegsTextBox1.Value,
				(int)m_MinsTextBox1.Value,
				(int)m_SecsTextBox1.Value)).ToString();
		}

		/// <summary>
		/// Handles the Execute event of the m_CalculateDMSFromDecimalAction control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void m_CalculateDMSFromDecimalAction_Execute(object sender, EventArgs e)
		{
			int degrees;
			int minutes;
			int seconds;

			ININ.GIS.GISUtilities.ConvertDoubleToSexagecimal(
				(double)m_DecimalTextBox2.Value,
				out degrees,
				out minutes,
				out seconds);

			m_DegsTextBox2.Text = degrees.ToString();
			m_MinsTextBox2.Text = minutes.ToString();
			m_SecsTextBox2.Text = seconds.ToString();
		}

		/// <summary>
		/// Handles the Execute event of the m_CalculateDecimalFromHMSAction control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void m_CalculateDecimalFromHMSAction_Execute(object sender, EventArgs e)
		{
			m_DecimalTextBox3.Text = (ININ.GIS.GISUtilities.ConvertHMSToDouble(
				(int)m_HrsTextBox1.Value,
				(int)m_MinsTextBox3.Value,
				(int)m_SecsTextBox3.Value)).ToString();
		}

		/// <summary>
		/// Handles the Execute event of the m_CalculateHMSFromDecimalAction control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void m_CalculateHMSFromDecimalAction_Execute(object sender, EventArgs e)
		{
			int hours;
			int minutes;
			int seconds;

			ININ.GIS.GISUtilities.ConvertDoubleToHMS(
				(double)m_DecimalTextBox4.Value,
				out hours,
				out minutes,
				out seconds);

			m_HrsTextBox2.Text = hours.ToString();
			m_MinsTextBox4.Text = minutes.ToString();
			m_SecsTextBox4.Text = seconds.ToString();
		}
		#endregion Actions
	}
}